package com.yequan.hbb.model;

import android.util.Log;

import com.yequan.hbb.entries.TuanTuanEntries;
import com.yequan.hbb.servers.Servers;
import com.yequan.hbb.utils.ServerUtil;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by DingLong on 2016/10/23.
 */

public class TuanModel extends MVPModel {
    private TuanCallBack tuanCallBack;

    public TuanModel(TuanCallBack tuanCallBack) {
        this.tuanCallBack = tuanCallBack;
    }

    public void getData() {
        Call<TuanTuanEntries> call = ServerUtil.createHttpRequest(Servers.class).getTuanInfo(10289,0,10);
        call.enqueue(new Callback<TuanTuanEntries>() {
            @Override
            public void onResponse(Call<TuanTuanEntries> call, Response<TuanTuanEntries> response) {
                tuanCallBack.onResponse(call,response);
            }

            @Override
            public void onFailure(Call<TuanTuanEntries> call, Throwable t) {
                Log.e("自定义标签", "类名==TuanModel" + "方法名==onFailure=====:" + "t==="+t);
                tuanCallBack.onFailure(call, t);

            }
        });
    }
    public interface TuanCallBack {
        void onResponse(Call<TuanTuanEntries> call, Response<TuanTuanEntries> response);

        void onFailure(Call<TuanTuanEntries> call, Throwable t);
    }
}
